home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Suzy B Software 2
/
Suzy B Software CD-ROM 2 (1994).iso
/
extras
/
programm
/
mcode_01
/
source
/
function
/
upper.s
< prev
Wrap
Text File
|
1995-04-27
|
2KB
|
50 lines
* Program : Converts a string to upper case
* Author : Stephen McNabb
* Creation date : 21th February 1995
* Last update : 21th February 1995
* Parameters : a0 needs to contain address of string to convert
* before jumping to the 'upper' routine
* Output : The string is converted to uppercase
start: jsr cls /clear the screen
move.l #mess1,d0 /move address of message to d0
jsr ptext /and display on screen
move.l #str,d0 /move address of string for conversion to d0
jsr ptext /and display on screen
jsr line /display a new line
move.l #str,a0 /move address of string for conversion to a0
jsr upper /and change it to lowercase
move.l #mess2,d0 /move address of message to d0
jsr ptext /and display on screen
move.l #str,d0 /move address of converted message to d0
jsr ptext /and display on screen
jsr line /dislay a new line
end: bra exit /exit from program
upper: movem.l d0,-(sp) /stack register
uloop: move.b (a0),d0 /move character of string to d0
cmpi.b #0,d0 /check if it is a null character
beq uend /if so then it is the end of the string
cmpi.b #'a',d0 /check if it is less than 'A'
blt unext /if so get another character
cmpi.b #'z',d0 /check if it is greater than 'Z'
bgt unext /if so get another chatacter
subi.b #32,d0 /else convert it to lowercase
move.b d0,(a0) /and move new character back to string
unext: add.l #1,a0 /increment a0 for next character
bra uloop /and loop
uend: movem.l (sp)+,d0 /unstack register
rts /return from subroutine
include "\SOURCE\FUNCTION.S" /include standard functions
*** Program Data ***
mess1: dc.b 'The string to convert to upper case is : ',0
mess2: dc.b 'The string is now : ',0
str: dc.b 'Convert THIS to Upper Case',0
*** End of File ***